<?php
if(!defined('PATH')) exit();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="distribution" content="Global" />
		<meta name="author" content="Vean" />
		<meta name="robots" content="index,follow" />
		<meta name="description" content="Site Description." />
		<meta name="keywords" content="ots, open tibia server, ..." />
		<title><?=$config['website']['title']?></title>
		<link href="<?=TEMPLATE . '/' .$config['website']['template']?>/main.css" rel="stylesheet" type="text/css" media="screen" />
		
		<script type="text/javascript">
			var RecaptchaOptions =
			{
				theme : '<?=$config['recaptcha']['theme']?>'
			};
		</script>
		<?=$scripts?>
	</head>
	<body>
		<div id="vt_page">
			<div id="vt_header"></div>
			<div id="vt_container">
				<div id="vt_menu">
					<div id="vt_news_menu">
						<div class="header">Main</div>
						<ul>
							<li><a href="<?=PATH?>/home/">Home</a></li>
							<li><a href="<?=PATH?>/news/">Latest News</a></li>
							<!-- <li><a href="<?=PATH?>/bugtracker">Bug Tracker</a></li> -->
						</ul>
					</div>
					<div id="vt_account_menu">
						<div class="header">Account</div>
						<ul>
							<?php if(LOGGED) { ?>
							<li><a href="<?=PATH?>/account/">Manage Account</a></li>
							<li><a href="<?=PATH?>/account/logout/">Logout</a></li>
							<?php } else { ?>
							<li><a href="<?=PATH?>/account/register/">Create Account</a></li>
							<li><a href="<?=PATH?>/account/">Login</a></li>
							<?php } ?>
						</ul>
					</div>
					<div id="vt_community_menu">
						<div class="header">Community</div>
						<ul>
							<li><a href="<?=PATH?>/search/">Characters</a></li>
							<li><a href="<?=PATH?>/highscores/">Highscores</a></li>
							<li><a href="<?=PATH?>/houses/">Houses</a></li>
							<li><a href="<?=PATH?>/online/">Online List</a></li>
							<li><a href="<?=PATH?>/deaths/">Latest Deaths</a></li>
							<li><a href="<?=PATH?>/guilds/">Guilds</a></li>
						</ul>
					</div>
				</div>
				<div id="vt_content">
					<div class="message">
						<div class="title"><?=$config['website']['controller_title']?></div>
					</div>
					<br />
					<?php
					
					echo $output;
					
					?>
				</div>
				<div id="vt_panel">
					<div class="top">
						<div class="bot">
							<div id="vt_panel_buttons">
								<a href="<?=PATH?>/downloads/" class="button">
									Downloads
									<span>Official downloads page</span>
								</a>
								<?php if($config['website']['forumStatus']) { ?>
								<a href="<?=$config['website']['forum']?>" class="button">
									Server Forum
									<span>Lead discussions about server life</span>
								</a>
								<?php } ?>
								<?php if ($config['website']['store']['status']) { ?>
								<a href="<?=PATH . $config['website']['store']['link']?>" class="button">
									Store
									<span>Something you can't avoid</span>
								</a>
								<?php } ?>
							</div>
						
							<div class="vt_panel_module">
					
					<p><b>Status:</b> <span style="float:right;color:<?=COLOR?>;"><?=strtoupper(STATUS)?></span><br /></p>
					
					<?php
					
					if(STATUS == 'online')
					{
						$playersOnline = $SQL->query('SELECT COUNT(`online`) FROM `players` WHERE `online` = 1')->fetch();
						
						echo '<b>Players online:</b><span style="float:right;">' . $playersOnline[0] . ' players</span><br />';
						
						$record = $SQL->query('SELECT `record` FROM `server_record` ORDER BY `record` DESC');
						
						foreach($record as $row)
						{
							echo '<b>Record:</b><span style="float:right;">' . $row['record'] . ' players</span><br />';
							break;
						}
					}
					
					?>
							</div>
							<?php
							if ($config['website']['top'] == true) {
							?>
							<div id="top">
							<b>Top 5 characters</b><br /><br />
							<?php
							
							$top = $SQL->query('SELECT `name`, `level`, `experience` FROM `players` WHERE `account_id` != 1 AND `group_id` < 2 ORDER BY `experience` DESC LIMIT 5')->fetchAll();
							$i = 1;
							
							foreach($top as $character) {
								$player = $ots->createObject('Player');
								$player->find($character['name']); 
								$color = ($player->isOnline()) ? '#1d7104' : '#666956';
								echo '<a href="' . PATH . '/search/check/' . urlencode($character['name']) . '">';
								echo '<span style="color:' . $color . ';">' . $character['name'] . '</span></a>';
								echo  '<span style="float:right;"><b>LEVEL:</b> '.$character['level'].'</span><br /><br />';
								$i++;
							}
							
							?>
							</div>
							<?php
							}
							?>
						</div>
					</div>
				</div>
			</div>
			<div id="vt_footer">
				<div class="column first">
					<img src="<?=TEMPLATE . '/' .$config['website']['template']?>/images/authornote.png" />
				</div>
				<div class="column second">
					<small>Worgen template by <a href="http://otland.net/members/vean/">Vean</a>, re-designed by <a href="http://otland.net/members/archez/">Archez</a>.</small><br />
					<small>Copyright &copy; 2011 <?=$config['server']['name']?>, all rights reserved.</small><br />
					<small>Page rendered in: <?=RENDER?>s</small><br /><br />
					<small><a href="<?=PATH?>/credits/"><?=FOOTER?> credits.</a></small>
				</div>
			</div>
		</div>
	</body>
</html>